/*
 * @Description: 订单 模型
 * @Author: zhhuan
 * @LastEditTime: 2024-03-27 19:23:59
 */
const mongoose = require("../db/db")

const Schema = mongoose.Schema(
  {
    username: {
      type: String,
      require: true
    },
    shopId: String,
    shopName: String,
    isCanceled: {
      type: Boolean,
      default: false
    }, //订单是否被取消
    address: {
      username: String,
      city: String,
      department: String,
      houseNumber: String,
      name: String,
      phone: String
    },
    products: [
      {
        product: {
          shopId: {
            type: String,
            require: true
          },
          name: String,
          imgUrl: String,
          sales: Number,
          price: Number,
          oldPrice: Number,
          tabs: [String]
        },
        orderSales: Number
      }
    ]
  },
  { timestamps: true }
)
const Order = mongoose.model("order", Schema)

module.exports = Order
